@extends('layouts.admin')
@section('title','角色添加')

@section('content')

    <!-- Main content -->
    <section class="content">
      <div class="col-md-6" style="width: 100%">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <div class="box-header with-border">
             
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal style-form" method="post" action="{{route('admin.role.update')}}">
              {{ csrf_field() }}
              <div class="box-body">
                 <input type="hidden" name="id"  value="{{$role->id}}">
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">角色</label>
                                <div class="col-sm-10">
                                    <input type="text"  class="form-control" name="name" id="name" placeholder="唯一标识如admin" value="{{$role->name}}">
                                    <lable class="error error_name"   style="display: inline-block;">{{$errors->first('name')}}</lable>
                                </div>
                                
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">角色名称</label>
                                <div class="col-sm-10">
                                    <input type="text"  class="form-control" name="display_name" id="display_name" placeholder="请输入角色名称" value="{{$role->display_name}}">
                                    <lable class="error error_display_name"   style="display: inline-block;">{{$errors->first('display_name')}}</lable>
                                </div>
                                
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">角色描述</label>
                                <div class="col-sm-10">
                                    <input type="text"  class="form-control" name="description" id="description" placeholder="请输入描述" value="{{$role->description}}">
                                    <lable class="error error_description"   style="display: inline-block;">{{$errors->first('description')}}</lable>
                                </div>
                               
                                
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">分配权限</label>
                                <div class="col-sm-10">
                                    <div>
                                        @foreach($permission as $v)
                                        <label class="checkbox-inline">
                                            <input type="checkbox"  id="inlineCheckbox1" name="permission[]" value="{{$v->id}}" @if(in_permission($v->id,$role->perms)) checked="checked" @endif>{{$v->display_name}}
                                        </label>
                                        @endforeach
                                    </div>
                                    <lable class="error error_description"   style="display: inline-block;">{{$errors->first('description')}}</lable>
                                </div>
                               
                                
                            </div>

                
               
              </div>
              <!-- /.box-body -->
              <div class="box-footer">
                <button type="button" class="btn btn-default" onClick="javascript:history.back()">返回</button>
                <button type="submit" class="btn btn-info pull-right ">提交</button>
              </div>
              <!-- /.box-footer -->
            </form>
          </div>
          <!-- /.box -->
          <!-- general form elements disabled -->
     
          <!-- /.box -->
        </div>
    </section>
    <!-- /.content -->
 


@endsection

 @section('script')
    <script src="{{asset('assets/js/jquery.validate.js')}}"></script>
    <script src="{{asset('assets/js/quanxian.js')}}"></script>
   
@endsection